<?php
import( 'de.ceus-media.framework.krypton.core.DefinitionAction' );
/**
 *	Log in Action.
 *	@package		mv2.action.authentification
 *	@extends		CMF_Krypton_Core_DefinitionAction
 *	@author			Christian W�rker <Christian.Wuerker@CeuS-Media.de>
 *	@since			23.04.2007
 *	@version		0.1
 */
/**
 *	Log in Action.
 *	@package		mv2.action.authentification
 *	@extends		CMF_Krypton_Core_DefinitionAction
 *	@author			Christian W�rker <Christian.Wuerker@CeuS-Media.de>
 *	@since			23.04.2007
 *	@version		0.1
 */
class Action_Authentication_Login extends CMF_Krypton_Core_DefinitionAction
{
	/**
	 *	Constructor.
	 *	@access		public
	 *	@return		void
	 */
	public function __construct()
	{
		parent::__construct();
		$this->loadLanguage( 'auth' );
		$this->addAction( 'loginUser' );
	}
		
	/**
	 *	Tries to log in an User.
	 *	@access		protected
	 *	@return		void
	 */
	protected function loginUser()
	{
		$request	= $this->registry->get( 'request' );
		$session	= $this->registry->get( 'session' );
		$auth		= $this->registry->get( 'auth' );
		$words		= $this->words['auth']['msg'];
		if( $auth->isAuthenticated() )
			return;
		try
		{
			if( $auth->login( $request->getAll() ) )
			{
				$this->messenger->noteSuccess( $words['success_login'] );
#				$this->restart( "./" );
			}
		}
		catch( Exception $e )
		{
			$this->handleException( $e, 'auth', 'loginUser' );
		}
	}
}
?>